package com.lzj.demo.controller;

import com.lzj.demo.dto.StudentQueryVo;
import com.lzj.demo.dto.Student;
import com.lzj.demo.service.StudentService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RequestMapping("/student")
@RestController
public class StudentController {

    @Resource
    private StudentService studentService;

    @PostMapping(value = "/get")
    public Student getStudentInfo(@RequestBody StudentQueryVo vo){
        return studentService.getStudentInfo(vo);
    }

    @PostMapping(value = "/getList")
    public List<Student> getStudentInfos(@RequestBody StudentQueryVo vo){
        return studentService.getStudentInfos(vo);
    }

    @GetMapping("scan/{limit}")
    public void scan(@PathVariable("limit") int limit) throws Exception {
         studentService.scan(limit);
    }

    @PostMapping(value = "/list")
    public List<Student> listAllStudent(){
        return studentService.listAllStudent();
    }

    @PostMapping(value = "/add")
    public Boolean addStudent(@RequestBody StudentQueryVo vo){
        return studentService.addStudent(vo);
    }

    @PostMapping(value = "/update")
    public Boolean updateStudent(@RequestBody StudentQueryVo vo){
        return studentService.updateStudent(vo);
    }

    @PostMapping(value = "/delete")
    public Boolean deleteStudent(@RequestBody StudentQueryVo vo){
        return studentService.deleteStudent(vo);
    }
}
